<?php
	require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
	gatekeeper();
	$chatsession = get_input("chatsession");
	// TODO: handle non-existing chat sessions
	$current_user_id = get_loggedin_userid();
?>



<div id="chat_menu" rel="<?php echo $chatsession;?>">	
	<div id="chat_menu_invite"><a href="javascript:inviteFriends(<?php echo $chatsession;?>)"><?php echo elgg_echo('elggchat:chat:invite');?></a></div>
	<div id="chat_menu_leave"><a href="javascript:leaveSession(<?php echo $chatsession;?>)"><?php echo elgg_echo('elggchat:chat:leave');?></a></div>
	<div id="chat_menu_info"><a href="javascript:showSessionInfo(<?php echo $chatsession;?>)"><?php echo elgg_echo('elggchat:chat:info');?></a></div>
</div>
<div id="chat_divs">
	<div id="chat_messages" rel="<?php echo $chatsession;?>">

		<div id="chat_data" rel="<?php echo $chatsession;?>"></div>

		<form id="chat_input" rel="<?php echo $chatsession;?>">
			<input type="hidden" name="chatsession" value="<?php echo $chatsession;?>">
			<input type="hidden" name="senderid" value="<?php echo $current_user_id;?>">
			<textarea name="chatmessage" rel="<?php echo $chatsession;?>" onkeypress="ifEnter(this,event, <?php echo $chatsession;?>);" style="width:100%"></textarea>
		</form>
	</div>

	<div id="chat_friends" rel="<?php echo $chatsession;?>"></div>
	<div id="chat_info" rel="<?php echo $chatsession;?>"></div>
	<div id="chat_loading" rel="<?php echo $chatsession;?>"><img src="<?php echo $CONFIG->wwwroot; ?>_graphics/ajax_loader.gif"></div>
</div>